Pause = class()

function Pause:init()
    self.renderGui = false
    self.backColor = color(0, 0, 0, 0)
    self.set = QuickSetting()
    self.back = STButton(WIDTH/2,HEIGHT/2 + 150,LP.backtogame,"Project:GB","Project:B")
    self.back.textColor = color(255, 255, 255, 255)
    self.back.width = 400
    self.back.clicked = function() 
        self.renderGui = false
        tween(0.4,self.backColor,{a = 0},tween.easing.linear,function()
            game.world:resume()
            GameState.State = Gaming
        end)
    end
    
    self.setting = STButton(WIDTH/2,HEIGHT/2 ,LP.setting,"Project:GB","Project:B")
    self.setting.textColor = color(255, 255, 255, 255)
    self.setting.width = 400
    self.setting.clicked = function() 
        self.set:show()
    end
            
    self.backtos = STButton(WIDTH/2,HEIGHT/2 - 150,LP.backtomenu,"Project:GB","Project:B")
    self.backtos.textColor = color(255, 255, 255, 255)
    self.backtos.width = 400
    self.backtos.clicked = function()
        GameState.State = Start     
        game:saveGame()
        game.world:resume()
    end
end

function Pause:pause()
    self.renderGui = true
    GameState.State = Pause
    game.world:pause()
    tween(1,self.backColor,{a = 180},tween.easing.cubicOut)
end

function Pause:draw()
    rectMode(CORNER)
    
    fill(self.backColor)
    rect(-5,-5,WIDTH+15,HEIGHT+15)
    if self.renderGui then
        self.back:draw()
        self.backtos:draw()
        self.setting:draw()
    end
    
    if self.set.showing == true then
        self.set:draw()
    end
end

function Pause:touched(touch)
    if self.set.showing == true then
        self.set:touched(touch)
        else
    if not self.renderGui then return end
    self.back:touched(touch)
    self.backtos:touched(touch)
    self.setting:touched(touch)
    end
end
